

module MC.Money {
    export enum PlayType {
        zhifubao = 1,
        weixin = 2,
    };

    export class chongzhi {
        private vm: any;

        public constructor() {
            MC.UI.Mui.loadbase();




            $('.chongzhibtn').click(() => {
                MC.click(() => {
                    this.genPlay();
                });
            });
            $('.moneyDiv .payType .zhifuli').click(function () {
                let one = $(this);
                $('.moneyDiv .payType .zhifuli').removeClass('on');
                one.addClass('on');
            });
            H5.TitleBar.create("充值");

        }

        public showinfo() {
            H5.TitleBar.create("完成充值",'',"/h5/my/money/index.html");
            let chongzhiobj = {
                out_trade_no: MC.OS.query('out_trade_no'),
                money: '',
                play_type_str: '',
                status_str: '',
                status:-1
            };
            this.vm = new Vue({
                el: '.myTable',
                data: chongzhiobj
            });
            let out_trade_no = MC.OS.query("out_trade_no");
            MC.apiD("getPaymentStatus", { out_trade_no: out_trade_no }, (data: any) => {
                console.log(data,chongzhiobj);
                /**money: "0.01"
                out_trade_no: "y202004210804488146"
                play_time: ""
                play_type: 1
                play_type_str: "支付宝web"
                status: 0
                status_str: "未支付" */
                chongzhiobj.money=data.money;
                chongzhiobj.play_type_str=data.play_type_str;
                chongzhiobj.status_str=data.status_str; 
                chongzhiobj.status=data.status; 

            });
        }

        private genPlay() {
            let val = $('.moneyvalue').val();
            if (val <= 0) {
                MC.msg.show('充值金额不能少于等于0');
                return;
            }
            let data_id = $('.moneyDiv .payType .zhifuli.on').attr('data-id');
            let playtype = 0;
            if (data_id == 'alipay') {///表示支付宝
                playtype = PlayType.zhifubao;
            } else if (data_id == 'wechat') {///微信
                playtype = PlayType.weixin;
            } else {
                MC.msg.show('选择错误');
                return;
            }
            ///playtype=11;
            MC.api('GenchongzhiPayHref', {
                playtype: playtype,
                value: val
            }, (obj: any) => {
                console.log(obj);
                window.open(obj, '_self');
            });
        }
    }
}